package mis.ds.ps.ui;

//Fri Oct 25 18:07:43 EST 2004
//
// Written by Sean R. Owens, sean at guild dot net, released to the
// public domain.  Share and enjoy.  Since some people argue that it is
// impossible to release software to the public domain, you are also free
// to use this code under any version of the GPL, LPGL, or BSD licenses,
// or contact me for use of another license.
// http://darksleep.com/player

// A very simple custom dialog that takes a string as a parameter,
// displays it in a JLabel, along with two Jbuttons, one labeled Yes,
// and one labeled No, and waits for the user to click one of them.

import javax.swing.*; 

import java.awt.Frame;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class DlgMapper extends JDialog implements ActionListener {
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JPanel myPanel;
	private JLabel jLabel1;
	private JTextField txtMapperName;
	private JButton btnOk, btnCancel;
	
    private boolean answer = false;
    public boolean getAnswer() { return answer; }

    public DlgMapper(Frame frame, boolean modal, String myMessage) {
        super(frame, modal);
        myPanel = new JPanel();
        getContentPane().add(myPanel);
        
        jLabel1 = new JLabel("Name: ");
        txtMapperName = new JTextField(20);
        btnOk = new JButton("Ok");
        btnOk.addActionListener(this);        
        btnCancel = new JButton("Cancel");
        btnCancel.addActionListener(this);
        
        myPanel.add(jLabel1);
        myPanel.add(txtMapperName);
        myPanel.add(btnOk);
        myPanel.add(btnCancel);
        pack();
        setLocationRelativeTo(frame);
        setVisible(true);
    }

    public void actionPerformed(ActionEvent e) {
        if(btnOk == e.getSource()) {
            System.err.println("User chose yes.");
            answer = true;
            setVisible(false);
        }
        else if(btnCancel == e.getSource()) {
            System.err.println("User chose no.");
            answer = false;
            setVisible(false);
        }
    }
    
}